﻿using System;
using Sinacor.Servico.Bovespa.Custodia.BusinessEntity;
using Sinacor.Servico.Bovespa.Custodia.Service.DataContract.Response;
using System.ComponentModel;
using System.Collections.Generic;


namespace Sinacor.Servico.Bovespa.Custodia.Service.ServiceImplementation.Translator
{
    public static class TranslateBetweenCustodiaAndCustodiaResponse
    {
        public static Sinacor.Servico.Bovespa.Custodia.BusinessEntity.Custodia TranslateCustodiaResponseToCustodia(Sinacor.Servico.Bovespa.Custodia.Service.DataContract.Response.CustodiaResponse from)
        {
            Sinacor.Servico.Bovespa.Custodia.BusinessEntity.Custodia to = new Sinacor.Servico.Bovespa.Custodia.BusinessEntity.Custodia();
            to.isContaInvestimento = from.isContaInvestimento;
            to.Titulo = from.Titulo;
            to.Carteira = from.Carteira;
            to.QuantidadeDisponivel = from.Disponivel;
            to.QuantidadeNegociavel = from.Negociavel;
            to.QuantidadeProjetado = from.Projetado;
            to.NegociosDia = from.NegociosDia;
            to.NegocioExecutar = from.NegocioExecutar;
            to.Anterior102004 = from.Anterior102004;
            to.Custo = from.Custo;
            to.ValorAtual = from.ValorAtual;
            to.Variacao = from.Variacao;
            to.PosicaoCustodia = from.PosicaoCustodia; 
            return to;
        }

        public static Sinacor.Servico.Bovespa.Custodia.Service.DataContract.Response.CustodiaResponse TranslateCustodiaToCustodiaResponse(Sinacor.Servico.Bovespa.Custodia.BusinessEntity.Custodia from)
        {
            Sinacor.Servico.Bovespa.Custodia.Service.DataContract.Response.CustodiaResponse to = new Sinacor.Servico.Bovespa.Custodia.Service.DataContract.Response.CustodiaResponse();
            to.isContaInvestimento = from.isContaInvestimento;
            to.Titulo = from.Titulo;
            to.Carteira = from.Carteira;
            to.Disponivel = from.QuantidadeDisponivel;
            to.Negociavel = from.QuantidadeNegociavel;
            to.Projetado = from.QuantidadeProjetado;
            to.NegociosDia = from.NegociosDia;
            to.NegocioExecutar = from.NegocioExecutar;
            to.Anterior102004 = from.Anterior102004;
            to.Custo = from.Custo;
            to.ValorAtual = from.ValorAtual;
            to.Variacao = from.Variacao;
            to.PosicaoCustodia = from.PosicaoCustodia; 
            return to;
        }

        public static List<
           Sinacor.Servico.Bovespa.Custodia.Service.DataContract.Response.CustodiaResponse>
           TranslateCustodiaListToCustodiaResponseList(List<Sinacor.Servico.Bovespa.Custodia.BusinessEntity.Custodia> from)
        {

            if (from == null) return null;
            List<Sinacor.Servico.Bovespa.Custodia.Service.DataContract.Response.CustodiaResponse> to = new List<CustodiaResponse>();
            foreach (Sinacor.Servico.Bovespa.Custodia.BusinessEntity.Custodia fromItem in from)
            {
                to.Add(TranslateCustodiaToCustodiaResponse(fromItem));
            }
            return to;

        }

        public static List<Sinacor.Servico.Bovespa.Custodia.BusinessEntity.Custodia>
   TranslateCustodiaResponseListToCustodiaList(List<Sinacor.Servico.Bovespa.Custodia.Service.DataContract.Response.CustodiaResponse> from)
        {
            if (from == null) return null;
            List<Sinacor.Servico.Bovespa.Custodia.BusinessEntity.Custodia> to = new List<Sinacor.Servico.Bovespa.Custodia.BusinessEntity.Custodia>();
            foreach (Sinacor.Servico.Bovespa.Custodia.Service.DataContract.Response.CustodiaResponse fromItem in from)
            {
                to.Add(TranslateCustodiaResponseToCustodia(fromItem));
            }
            return to;

        }
    }
}
